package com.fzy.core.system.action;

import ge.core.system.entity.Mapping;
import ge.core.system.entity.Module;

import java.util.Date;

import com.fzy.core.system.service.DbService;
import com.fzy.core.utils.U;
import com.fzy.core.webwork.BaseAction;
import com.fzy.core.webwork.MyValidationAware;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;

public class ModuleSaveAction extends BaseAction implements Preparable, MyValidationAware, ModelDriven {

	private static final long serialVersionUID = -55725527522956019L;
	
	String errorDispatch;
	Module module;
	DbService dbService;

	public void prepare() throws Exception {
		errorDispatch = "dispatcher:/pages/refresh-parent.jsp";
		module = (Module)validateIdAndGetEntity(request.getParameter("id"), Module.class);
        
		// default values
        if(module == null){
        	module = new Module();
        	module.setPackageText("ge.app");
    		module.setNameText("app");
    		module.setPrefixText("ru");
    		module.setNameShow("应用");
        }
	}

	public void validate() {

	}

	public String execute() throws Exception {
		dbService.saveEntityId(module);

		addActionMessage(getText("success.save"));
		return "dispatcher:/pages/refresh-parent.jsp";
	}

	public Object getModel() {
		return module;
	}

	public String getErrorDispatch() {
		return errorDispatch;
	}

	public void setDbService(DbService dbService) {
		this.dbService = dbService;
	}

}
